<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="GermPlasmSchema" targetNamespace="http://www.mpimp-golm.mpg.de/2007/GermPlasm" elementFormDefault="qualified" xmlns="http://www.mpimp-golm.mpg.de/2007/GermPlasm" xmlns:gp="http://www.mpimp-golm.mpg.de/2007/GermPlasm" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Stock">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="SpeciesRepository" minOccurs="1" maxOccurs="1" type="TTermRepository">
        </xs:element>
        <xs:element name="TransgenicRepository" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Transgenic" type="TTransgenicConstruct" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="GermPlasm" type="TGermplasm" minOccurs="0" maxOccurs="unbounded">
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:key name="GermPlasmId">
      <xs:selector xpath=".//gp:GermPlasm" />
      <xs:field xpath="@Identifier" />
    </xs:key>
    <xs:unique name="StockKey_SpeciesId">
      <xs:selector xpath=".//gp:Species" />
      <xs:field xpath="@BinomialName" />
    </xs:unique>
    <xs:key name="StockKey_SubSpecies">
      <xs:selector xpath=".//gp:SubSpecies" />
      <xs:field xpath="@Name" />
      <xs:field xpath="@species" />
    </xs:key>
    <xs:key name="StockKey_Ecotype">
      <xs:selector xpath=".//gp:Ecotype" />
      <xs:field xpath="@Name" />
      <xs:field xpath="@species" />
    </xs:key>
    <xs:key name="StockKey_Cultivar">
      <xs:selector xpath=".//gp:Cultivar" />
      <xs:field xpath="@Name" />
      <xs:field xpath="@species" />
    </xs:key>
    <xs:unique name="StockKey_NCBI">
      <xs:selector xpath=".//gp:Species|.//gp:SubSpecies|.//gp:Cultivar" />
      <xs:field xpath="@NCBITaxId" />
    </xs:unique>
    <xs:key name="StockKey_SpeciesID">
      <xs:selector xpath=".//gp:Species" />
      <xs:field xpath="@Id" />
    </xs:key>
    <xs:key name="StockKey_TransgenicContruct">
      <xs:selector xpath=".//gp:TransgenicRef" />
      <xs:field xpath="@transgenic" />
    </xs:key>
    <xs:key name="StockKey_Transgenic">
      <xs:selector xpath=".//gp:Transgenic" />
      <xs:field xpath="@Identifier" />
    </xs:key>
  </xs:element>
  <xs:complexType name="TGermplasm">
    <xs:complexContent>
      <xs:extension base="TQualifiable">
        <xs:sequence>
          <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="EcotypeRef" type="TEcotypeRef">
              <xs:keyref name="Ecotype_EcotypeRef" refer="StockKey_Ecotype">
                <xs:selector xpath="." />
                <xs:field xpath="@ecotype" />
                <xs:field xpath="@species" />
              </xs:keyref>
            </xs:element>
            <xs:element name="CultivarRef" type="TCultivarRef">
              <xs:keyref name="Cultivar_CultivarRef" refer="StockKey_Cultivar">
                <xs:selector xpath="." />
                <xs:field xpath="@cultivar" />
                <xs:field xpath="@species" />
              </xs:keyref>
            </xs:element>
            <xs:element name="SubSpeciesRef" type="TSubSpeciesRef">
              <xs:keyref name="SubSpeciesSubSpeciesRef" refer="StockKey_SubSpecies">
                <xs:selector xpath="." />
                <xs:field xpath="@subspecies" />
                <xs:field xpath="@species" />
              </xs:keyref>
            </xs:element>
            <xs:element name="SpeciesRef" type="TSpeciesRef">
              <xs:keyref name="Species_SpeciesRef" refer="StockKey_SpeciesId">
                <xs:selector xpath="." />
                <xs:field xpath="@species" />
              </xs:keyref>
            </xs:element>
          </xs:choice>
          <xs:element name="Mutant" type="TMutant" minOccurs="0" maxOccurs="1" />
          <xs:element name="TransgenicRef" type="TContructRef" minOccurs="0" maxOccurs="1">
            <xs:keyref name="Transgenic_TransgenicRef" refer="StockKey_Transgenic">
              <xs:selector xpath="." />
              <xs:field xpath="@transgenic" />
            </xs:keyref>
          </xs:element>
          <!--<xs:element name="Quantifier" type="TQuantifier" minOccurs="0" maxOccurs="unbounded" />-->
        </xs:sequence>
        <xs:attribute name="Identifier" type="xs:Name" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="TEcotype">
    <xs:complexContent>
      <xs:extension base="TQualifiable">
        <xs:sequence>
        </xs:sequence>
        <xs:attribute name="Habitat" type="xs:string" />
        <xs:attribute name="Location" type="xs:string" />
        <xs:attribute name="CollectedWhen" type="xs:date" />
        <xs:attribute name="CollecteByWhom" type="xs:string" />
        <xs:attribute name="Name" type="xs:Name" />
        <xs:attribute name="species" type="xs:token" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="TQualifier" mixed="1">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:normalizedString" use="required" />
  </xs:complexType>
  <xs:complexType name="TSpeciesRef">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="species" type="xs:token" use="required" />
  </xs:complexType>
  <xs:complexType name="TTransgenicConstruct">
    <xs:sequence />
    <xs:attribute name="Identifier" type="xs:int" />
    <xs:attribute name="InsertType" type="TInsertType" use="required" />
    <xs:attribute name="ConstructType" type="TConstructType" />
    <xs:attribute name="GeneName" type="xs:string" use="optional" />
    <xs:attribute name="Locus" type="xs:string" use="required" />
    <xs:attribute name="ProteinFusion" type="xs:string" />
    <xs:attribute name="Unknown" type="xs:boolean" />
    <xs:attribute name="SimpleInsert" type="xs:boolean" />
  </xs:complexType>
  <xs:complexType name="TQualifiable" abstract="true">
    <xs:sequence>
      <xs:element name="Qualifier" type="TQualifier" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TMutant">
    <xs:complexContent>
      <xs:extension base="TQualifiable">
        <xs:sequence />
        <xs:attribute name="Name" type="xs:token" use="required" />
        <xs:attribute name="MutaGene" type="xs:string" />
        <xs:attribute name="GeneName" type="xs:string" />
        <xs:attribute name="Locus" type="xs:string" />
        <xs:attribute name="Inheritance" type="xs:string" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="TCultivar">
    <xs:complexContent>
      <xs:extension base="TQualifiable">
        <xs:sequence />
        <xs:attribute name="Name" type="xs:Name" />
        <xs:attribute name="species" type="xs:token" />
        <xs:attribute name="NCBITaxId" type="xs:int" use="optional" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="TContructRef">
    <xs:sequence />
    <xs:attribute name="transgenic" type="xs:int" use="required" />
  </xs:complexType>
  <xs:complexType name="TGenusSpec">
    <xs:sequence>
      <xs:element name="Species" maxOccurs="unbounded" minOccurs="0" type="TSpecies">
        <!--<xs:key name="GenusSpecies-IdKey">
          <xs:selector xpath="." />
          <xs:field xpath="@Id" />
        </xs:key>-->
      </xs:element>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:Name" use="required" />
  </xs:complexType>
  <xs:complexType name="TSubSpecies">
    <xs:complexContent>
      <xs:extension base="TQualifiable">
        <xs:sequence />
        <xs:attribute name="NCBITaxId" type="xs:int" />
        <xs:attribute name="species" type="xs:token" />
        <xs:attribute name="Name" type="xs:Name" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="TTermRepository">
    <xs:sequence>
      <xs:element name="Genus" minOccurs="1" maxOccurs="unbounded" type="TGenusSpec">
        <!--<xs:key name="GenusKey">
                  <xs:selector xpath=".//mstns:GenusDef" />
                  <xs:field xpath="@Name" />
                </xs:key>-->
      </xs:element>
      <xs:element name="SubSpecies" type="TSubSpecies" minOccurs="0" maxOccurs="unbounded">
        <xs:keyref name="Species_SubSpecies" refer="StockKey_SpeciesId">
          <xs:selector xpath="." />
          <xs:field xpath="@species" />
        </xs:keyref>
      </xs:element>
      <xs:element name="Ecotype" type="TEcotype" minOccurs="0" maxOccurs="unbounded">
        <xs:keyref name="Species_Ecotype" refer="StockKey_SpeciesId">
          <xs:selector xpath="." />
          <xs:field xpath="@species" />
        </xs:keyref>
      </xs:element>
      <xs:element name="Cultivar" type="TCultivar" minOccurs="0" maxOccurs="unbounded">
        <xs:keyref name="Species_Cultivar" refer="StockKey_SpeciesId">
          <xs:selector xpath="." />
          <xs:field xpath="@species" />
        </xs:keyref>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="TSpecies">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:Name" use="required" />
    <xs:attribute name="BinomialName" type="xs:token" use="required" />
    <xs:attribute name="Id" type="xs:Name" use="required" />
    <xs:attribute name="NCBITaxId" type="xs:int" />
  </xs:complexType>
  <xs:complexType name="TEcotypeRef">
    <xs:sequence />
    <xs:attribute name="ecotype" type="xs:Name" />
    <xs:attribute name="species" type="xs:token" />
  </xs:complexType>
  <xs:complexType name="TBaseRef">
    <xs:sequence>
    </xs:sequence>
    <xs:attribute name="ref" type="xs:token" use="required" />
  </xs:complexType>
  <xs:complexType name="TSubSpeciesRef">
    <xs:sequence />
    <xs:attribute name="species" type="xs:token" />
    <xs:attribute name="subspecies" type="xs:Name" use="required" />
  </xs:complexType>
  <xs:complexType name="TCultivarRef">
    <xs:sequence />
    <xs:attribute name="cultivar" type="xs:Name" />
    <xs:attribute name="species" type="xs:token" />
  </xs:complexType>
  <xs:simpleType name="TInsertType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="cDNA" />
      <xs:enumeration value="genomic construct" />
      <xs:enumeration value="transposon" />
      <xs:enumeration value="T-DNA" />
      <xs:enumeration value="inverted_repeat" />
      <xs:enumeration value="unknown" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="TConstructType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="activation_tag" />
      <xs:enumeration value="gene_trap" />
      <xs:enumeration value="enhancer_trap" />
      <xs:enumeration value="promoter_trap" />
      <xs:enumeration value="promoter_reporter" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>